package com.alan.observer.jdk;

import java.util.Observable;
import java.util.Observer;

/**
 * Created by Alan on 2018/8/21.
 */
public class JDKUser implements Observer {

    private String name;

    public JDKUser(String name) {
        this.name = name;
    }

    @Override
    public void update(Observable o, Object arg) {
        if(arg instanceof String){
            System.out.println(name + "收到微信推送 : " + (String) arg);
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    public static void main(String[] args){
        JDKUser user1 = new JDKUser("张三");
        JDKUser user2 = new JDKUser("李四");
        WeChatServer server = WeChatServer.getInstance();
        server.addObserver(user1);
        server.addObserver(user2);

        server.getMessage("明天放假！");
    }
}
